package com.gupao.javavip.netty.push.client;

import com.gupao.javavip.netty.push.client.processor.handler.MultiplePushMsgRequestClientHandler;
import com.gupao.javavip.netty.push.client.processor.handler.MultiplePushMsgResponseClientHandler;
import com.gupao.javavip.netty.push.protocol.AbstractPushClientChannelInitializer;
import io.netty.channel.ChannelInitializer;
import io.netty.channel.socket.SocketChannel;
import lombok.extern.apachecommons.CommonsLog;

@CommonsLog
public class MultiplePushMsgClient extends AbstractPushClient {
    public MultiplePushMsgClient(String host, int port) {
        super(host, port);
    }

    @Override
    protected ChannelInitializer<SocketChannel> buildHandler() {
        return new AbstractPushClientChannelInitializer() {
            @Override
            protected void doInitPushClientChannel(SocketChannel ch) {
                //Inbound
                ch.pipeline().addLast("multiple-push-msg-request-client-handler", new MultiplePushMsgRequestClientHandler());
                ch.pipeline().addLast("multiple-push-msg-response-client-handler", new MultiplePushMsgResponseClientHandler());
            }
        };
    }

    public static void main(String[] args) {
        new MultiplePushMsgClient("localhost", 8080).start();
    }
}
